package com.hisoft.service;

import com.hisoft.dao.ItemMapper;
import com.hisoft.pojo.Item;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: mybatisspring
 * @description:
 * @author: wlg
 * @create: 2021-09-28 09:33:45
 **/
@Service("itemService")
@Transactional
public class ItemServiceImpl implements ItemService{
    @Resource
    private ItemMapper itemMapper;
    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED,readOnly = true)
    public List<Item> queryItems() {
        return itemMapper.queryAllItems();
    }

    @Override
    @Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
    public int saveItem(Item item) {
        int count = itemMapper.insert(item);
        int a = 1/0;
//        item.update();
        return count;
    }
}
